package com.zenchn.dynamic;

import static com.zenchn.dynamic.TMiCustomerCompletionDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TMiCustomerCompletion;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TMiCustomerCompletionDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    BasicColumn[] selectList = BasicColumn.columnList(completionId, accountId, month, agentTarget, agentL2Target, agentL3Target, hospitalTarget, hospitalL2Target, hospitalL3Target, agentCompletion, agentL2Completion, agentL3Completion, agentVisit, hospitalCompletion, hospitalL2Completion, hospitalL3Completion, hospitalVisit, creator, createTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TMiCustomerCompletion> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TMiCustomerCompletion> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TMiCustomerCompletionResult")
    Optional<TMiCustomerCompletion> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TMiCustomerCompletionResult", value = {
        @Result(column="completion_id", property="completionId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="account_id", property="accountId", jdbcType=JdbcType.CHAR),
        @Result(column="month", property="month", jdbcType=JdbcType.VARCHAR),
        @Result(column="agent_target", property="agentTarget", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_l2_target", property="agentL2Target", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_l3_target", property="agentL3Target", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_target", property="hospitalTarget", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_l2_target", property="hospitalL2Target", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_l3_target", property="hospitalL3Target", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_Completion", property="agentCompletion", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_l2_Completion", property="agentL2Completion", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_l3_Completion", property="agentL3Completion", jdbcType=JdbcType.INTEGER),
        @Result(column="agent_visit", property="agentVisit", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_Completion", property="hospitalCompletion", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_l2_Completion", property="hospitalL2Completion", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_l3_Completion", property="hospitalL3Completion", jdbcType=JdbcType.INTEGER),
        @Result(column="hospital_visit", property="hospitalVisit", jdbcType=JdbcType.INTEGER),
        @Result(column="creator", property="creator", jdbcType=JdbcType.CHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TMiCustomerCompletion> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TMiCustomerCompletion, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TMiCustomerCompletion, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int deleteByPrimaryKey(String completionId_) {
        return delete(c ->
            c.where(completionId, isEqualTo(completionId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int insert(TMiCustomerCompletion record) {
        return MyBatis3Utils.insert(this::insert, record, TMiCustomerCompletion, c ->
            c.map(completionId).toProperty("completionId")
            .map(accountId).toProperty("accountId")
            .map(month).toProperty("month")
            .map(agentTarget).toProperty("agentTarget")
            .map(agentL2Target).toProperty("agentL2Target")
            .map(agentL3Target).toProperty("agentL3Target")
            .map(hospitalTarget).toProperty("hospitalTarget")
            .map(hospitalL2Target).toProperty("hospitalL2Target")
            .map(hospitalL3Target).toProperty("hospitalL3Target")
            .map(agentCompletion).toProperty("agentCompletion")
            .map(agentL2Completion).toProperty("agentL2Completion")
            .map(agentL3Completion).toProperty("agentL3Completion")
            .map(agentVisit).toProperty("agentVisit")
            .map(hospitalCompletion).toProperty("hospitalCompletion")
            .map(hospitalL2Completion).toProperty("hospitalL2Completion")
            .map(hospitalL3Completion).toProperty("hospitalL3Completion")
            .map(hospitalVisit).toProperty("hospitalVisit")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int insertMultiple(Collection<TMiCustomerCompletion> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TMiCustomerCompletion, c ->
            c.map(completionId).toProperty("completionId")
            .map(accountId).toProperty("accountId")
            .map(month).toProperty("month")
            .map(agentTarget).toProperty("agentTarget")
            .map(agentL2Target).toProperty("agentL2Target")
            .map(agentL3Target).toProperty("agentL3Target")
            .map(hospitalTarget).toProperty("hospitalTarget")
            .map(hospitalL2Target).toProperty("hospitalL2Target")
            .map(hospitalL3Target).toProperty("hospitalL3Target")
            .map(agentCompletion).toProperty("agentCompletion")
            .map(agentL2Completion).toProperty("agentL2Completion")
            .map(agentL3Completion).toProperty("agentL3Completion")
            .map(agentVisit).toProperty("agentVisit")
            .map(hospitalCompletion).toProperty("hospitalCompletion")
            .map(hospitalL2Completion).toProperty("hospitalL2Completion")
            .map(hospitalL3Completion).toProperty("hospitalL3Completion")
            .map(hospitalVisit).toProperty("hospitalVisit")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int insertSelective(TMiCustomerCompletion record) {
        return MyBatis3Utils.insert(this::insert, record, TMiCustomerCompletion, c ->
            c.map(completionId).toPropertyWhenPresent("completionId", record::getCompletionId)
            .map(accountId).toPropertyWhenPresent("accountId", record::getAccountId)
            .map(month).toPropertyWhenPresent("month", record::getMonth)
            .map(agentTarget).toPropertyWhenPresent("agentTarget", record::getAgentTarget)
            .map(agentL2Target).toPropertyWhenPresent("agentL2Target", record::getAgentL2Target)
            .map(agentL3Target).toPropertyWhenPresent("agentL3Target", record::getAgentL3Target)
            .map(hospitalTarget).toPropertyWhenPresent("hospitalTarget", record::getHospitalTarget)
            .map(hospitalL2Target).toPropertyWhenPresent("hospitalL2Target", record::getHospitalL2Target)
            .map(hospitalL3Target).toPropertyWhenPresent("hospitalL3Target", record::getHospitalL3Target)
            .map(agentCompletion).toPropertyWhenPresent("agentCompletion", record::getAgentCompletion)
            .map(agentL2Completion).toPropertyWhenPresent("agentL2Completion", record::getAgentL2Completion)
            .map(agentL3Completion).toPropertyWhenPresent("agentL3Completion", record::getAgentL3Completion)
            .map(agentVisit).toPropertyWhenPresent("agentVisit", record::getAgentVisit)
            .map(hospitalCompletion).toPropertyWhenPresent("hospitalCompletion", record::getHospitalCompletion)
            .map(hospitalL2Completion).toPropertyWhenPresent("hospitalL2Completion", record::getHospitalL2Completion)
            .map(hospitalL3Completion).toPropertyWhenPresent("hospitalL3Completion", record::getHospitalL3Completion)
            .map(hospitalVisit).toPropertyWhenPresent("hospitalVisit", record::getHospitalVisit)
            .map(creator).toPropertyWhenPresent("creator", record::getCreator)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default Optional<TMiCustomerCompletion> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TMiCustomerCompletion, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default List<TMiCustomerCompletion> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TMiCustomerCompletion, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default List<TMiCustomerCompletion> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TMiCustomerCompletion, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default Optional<TMiCustomerCompletion> selectByPrimaryKey(String completionId_) {
        return selectOne(c ->
            c.where(completionId, isEqualTo(completionId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TMiCustomerCompletion, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    static UpdateDSL<UpdateModel> updateAllColumns(TMiCustomerCompletion record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(completionId).equalTo(record::getCompletionId)
                .set(accountId).equalTo(record::getAccountId)
                .set(month).equalTo(record::getMonth)
                .set(agentTarget).equalTo(record::getAgentTarget)
                .set(agentL2Target).equalTo(record::getAgentL2Target)
                .set(agentL3Target).equalTo(record::getAgentL3Target)
                .set(hospitalTarget).equalTo(record::getHospitalTarget)
                .set(hospitalL2Target).equalTo(record::getHospitalL2Target)
                .set(hospitalL3Target).equalTo(record::getHospitalL3Target)
                .set(agentCompletion).equalTo(record::getAgentCompletion)
                .set(agentL2Completion).equalTo(record::getAgentL2Completion)
                .set(agentL3Completion).equalTo(record::getAgentL3Completion)
                .set(agentVisit).equalTo(record::getAgentVisit)
                .set(hospitalCompletion).equalTo(record::getHospitalCompletion)
                .set(hospitalL2Completion).equalTo(record::getHospitalL2Completion)
                .set(hospitalL3Completion).equalTo(record::getHospitalL3Completion)
                .set(hospitalVisit).equalTo(record::getHospitalVisit)
                .set(creator).equalTo(record::getCreator)
                .set(createTime).equalTo(record::getCreateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TMiCustomerCompletion record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(completionId).equalToWhenPresent(record::getCompletionId)
                .set(accountId).equalToWhenPresent(record::getAccountId)
                .set(month).equalToWhenPresent(record::getMonth)
                .set(agentTarget).equalToWhenPresent(record::getAgentTarget)
                .set(agentL2Target).equalToWhenPresent(record::getAgentL2Target)
                .set(agentL3Target).equalToWhenPresent(record::getAgentL3Target)
                .set(hospitalTarget).equalToWhenPresent(record::getHospitalTarget)
                .set(hospitalL2Target).equalToWhenPresent(record::getHospitalL2Target)
                .set(hospitalL3Target).equalToWhenPresent(record::getHospitalL3Target)
                .set(agentCompletion).equalToWhenPresent(record::getAgentCompletion)
                .set(agentL2Completion).equalToWhenPresent(record::getAgentL2Completion)
                .set(agentL3Completion).equalToWhenPresent(record::getAgentL3Completion)
                .set(agentVisit).equalToWhenPresent(record::getAgentVisit)
                .set(hospitalCompletion).equalToWhenPresent(record::getHospitalCompletion)
                .set(hospitalL2Completion).equalToWhenPresent(record::getHospitalL2Completion)
                .set(hospitalL3Completion).equalToWhenPresent(record::getHospitalL3Completion)
                .set(hospitalVisit).equalToWhenPresent(record::getHospitalVisit)
                .set(creator).equalToWhenPresent(record::getCreator)
                .set(createTime).equalToWhenPresent(record::getCreateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int updateByPrimaryKey(TMiCustomerCompletion record) {
        return update(c ->
            c.set(accountId).equalTo(record::getAccountId)
            .set(month).equalTo(record::getMonth)
            .set(agentTarget).equalTo(record::getAgentTarget)
            .set(agentL2Target).equalTo(record::getAgentL2Target)
            .set(agentL3Target).equalTo(record::getAgentL3Target)
            .set(hospitalTarget).equalTo(record::getHospitalTarget)
            .set(hospitalL2Target).equalTo(record::getHospitalL2Target)
            .set(hospitalL3Target).equalTo(record::getHospitalL3Target)
            .set(agentCompletion).equalTo(record::getAgentCompletion)
            .set(agentL2Completion).equalTo(record::getAgentL2Completion)
            .set(agentL3Completion).equalTo(record::getAgentL3Completion)
            .set(agentVisit).equalTo(record::getAgentVisit)
            .set(hospitalCompletion).equalTo(record::getHospitalCompletion)
            .set(hospitalL2Completion).equalTo(record::getHospitalL2Completion)
            .set(hospitalL3Completion).equalTo(record::getHospitalL3Completion)
            .set(hospitalVisit).equalTo(record::getHospitalVisit)
            .set(creator).equalTo(record::getCreator)
            .set(createTime).equalTo(record::getCreateTime)
            .where(completionId, isEqualTo(record::getCompletionId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_completion")
    default int updateByPrimaryKeySelective(TMiCustomerCompletion record) {
        return update(c ->
            c.set(accountId).equalToWhenPresent(record::getAccountId)
            .set(month).equalToWhenPresent(record::getMonth)
            .set(agentTarget).equalToWhenPresent(record::getAgentTarget)
            .set(agentL2Target).equalToWhenPresent(record::getAgentL2Target)
            .set(agentL3Target).equalToWhenPresent(record::getAgentL3Target)
            .set(hospitalTarget).equalToWhenPresent(record::getHospitalTarget)
            .set(hospitalL2Target).equalToWhenPresent(record::getHospitalL2Target)
            .set(hospitalL3Target).equalToWhenPresent(record::getHospitalL3Target)
            .set(agentCompletion).equalToWhenPresent(record::getAgentCompletion)
            .set(agentL2Completion).equalToWhenPresent(record::getAgentL2Completion)
            .set(agentL3Completion).equalToWhenPresent(record::getAgentL3Completion)
            .set(agentVisit).equalToWhenPresent(record::getAgentVisit)
            .set(hospitalCompletion).equalToWhenPresent(record::getHospitalCompletion)
            .set(hospitalL2Completion).equalToWhenPresent(record::getHospitalL2Completion)
            .set(hospitalL3Completion).equalToWhenPresent(record::getHospitalL3Completion)
            .set(hospitalVisit).equalToWhenPresent(record::getHospitalVisit)
            .set(creator).equalToWhenPresent(record::getCreator)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .where(completionId, isEqualTo(record::getCompletionId))
        );
    }
}
